/**
 * Copyright (C) 2018-2022
 * All rights reserved, Designed By www.yixiang.co
 * 注意：
 * 本软件为www.yixiang.co开发研制，未经购买不得使用
 * 购买后可获得全部源代码（禁止转卖、分享、上传到码云、github等开源平台）
 * 一经发现盗用、分享等行为，将追究法律责任，后果自负
 */
package co.yixiang.yshop.module.message.controller.app.template;

import co.yixiang.yshop.framework.common.pojo.CommonResult;
import co.yixiang.yshop.framework.security.core.annotations.PreAuthenticated;
import co.yixiang.yshop.module.message.controller.admin.wechattemplate.vo.WechatTemplateExportReqVO;
import co.yixiang.yshop.module.message.dal.dataobject.wechattemplate.WechatTemplateDO;
import co.yixiang.yshop.module.message.enums.WechatTempateEnum;
import co.yixiang.yshop.module.message.service.wechattemplate.WechatTemplateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

import static co.yixiang.yshop.framework.common.pojo.CommonResult.success;

/**
 * <p>
 * 模板消息控制器
 * </p>
 *
 * @author hupeng
 * @since 2025-4-1
 */
@Slf4j
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Tag(name = "用户 APP - 模板消息")
@RequestMapping("/template")
public class AppTemplateController {

    private final WechatTemplateService wechatTemplateService;



    /**
     * 小程序模板消息
     */
    @PreAuthenticated
    @GetMapping("/list")
    @Operation(summary = "小程序模板消息列表")
    public CommonResult<List<String>> getList() {
        List<WechatTemplateDO> list = wechatTemplateService.getWechatTemplateList(new WechatTemplateExportReqVO()
                .setType(WechatTempateEnum.SUBSCRIBE.getValue()));
        List<String> stringList = list.stream().map(WechatTemplateDO::getTempid).collect(Collectors.toList());
        return success(stringList);
    }




}

